#!/bin/sh

export CFLG="-D___SYS_I486 -D___OS_LIN"
export GFLG="-D___GUI"
export IFLG="-I. -Ilib"
export LIBS="-lm -ldl -lpthread"
export LIBS="$LIBS -lgcc -lc -lgcc"

if [ "$1" == "-g" ]; then
  export CFLG="$CFLG $GFLG"
  export LIBS="$LIBS -lSDL_ttf -lSDL"
  shift
fi
if [ "$1" == "-l" ]; then
  export LIB="-ljpgbmp"
  shift
fi
if [ "$1" == "-x" ]; then
  export CFLG="$CFLG -D___DLLIMP"
  export LIB="$LIB-dll"
  shift
fi
if [ "$1" == "" ]; then
  echo "Args: [-g] [-l] [-x] <name>"
  exit 0
fi
export NAM=$1
shift

echo CFLG=$CFLG
gcc -s -O2 -Wall -o $NAM.x $CFLG $IFLG $NAM.c -L. $LIB $LIBS
